<template>
  <div class="content">
    <v-header></v-header>
    <p>{{joke.text}}</p>
    <span class="sub-title">{{joke.passtime}}</span>
    <!-- video/image/gif/text -->
    <div>
      <img class="img" v-if="joke.type== 'image' || joke.type == 'gif'" :src="joke.images">
      <p v-if="joke.type== 'text'">
        {{joke.text}}
      </p>
      <video class="video" v-if="joke.type== 'video'" :src="joke.video"
        controls="controls" autoplay></video>
    </div>
  </div>
</template>

<script>
import vHeader from './header'
import axios from 'axios'
import {getSingleJoke} from '../../sever'
export default {
  data () {
    return {
      joke: {}
    }
  },
  components: {
    vHeader
  },
  created() {
    this.getJoke()
  },
  methods: {
    getJoke(){
      axios.get(getSingleJoke, {
        params: {
          sid: this.$route.params.sid
        }
      })
        .then(res => {
          console.log(res.data)
          this.joke = res.data.result
        })
        .catch(err => {
          console.log(err)
        })
    }
  }
}
</script>

<style scoped>
  .content {
    min-height: 100vh;
    width: 800px;
    margin: 0 auto;
    border-left: 1px solid #666;
    border-right: 1px solid #666;
  }
  .sub-title {
    color: #999;
    font-size: 12px;
    text-align: right;
    display: block;
    margin-right: 20px;
  }
  .video {
    width: 100%;
    height: 600px;
  }
  .img {
    width: 100%;
  }
</style>
